package org.springblade.pm.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author LK
 * @version 1.0.0
 * @Title: DynamicRoutingDataSource.java
 * @Description: TODO
 * @date 2020/5/20 11:10
 */
@Slf4j
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {

	@Override
	protected Object determineCurrentLookupKey() {
		String dataSourceName = DynamicDataSourceContextHolder.getDataSourceRouterKey();
		log.info("当前数据源是：{}", dataSourceName);
		return DynamicDataSourceContextHolder.getDataSourceRouterKey();
	}
}
